<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: token, Origin,x-csrf-token, X-Requested-With, Content-Type, Accept, Authorization");
header('Access-Control-Allow-Methods: POST,GET,PUT,DELETE');
/////////////////////////功能方法开始/////////////////////////////
$prefix="qier_";
//远程服务器
 function ser_redis($select=0){
    $redisObj = new \Redis();
    $redisObj->connect('43.227.218.56',6379);
    $redisObj->auth('gznet100');
    $redisObj->select($select); //设置密码
    return $redisObj;
  }
//本地服务器
 function cli_redis($select=0){
    $redisObj = new \Redis();
    $redisObj->connect('127.0.0.1',6379);
    $redisObj->auth('gznet100');
    $redisObj->select($select); //设置密码
    return $redisObj;
  }
/////////////////////////功能方法结束//////////////////////////
function get_value($dataname='',$get_time=1,$location=1){
  //$dataname=;
  //$get_time=1;//本地缓存时间
  //初始化服务器
  
  $cli_redis=cli_redis(1);
  //本地的先看一下
  $xdata=$cli_redis->get($dataname);
  if(!$xdata&&$location){
    $ser_redis=ser_redis(1);
    $xdata=$ser_redis->get($dataname);
    $cli_redis->set($dataname,$xdata,$get_time);
  }
  return $xdata;
}
echo get_value($prefix.'str_psgeorder',1,0);//缓存1秒在本地
?>